<div class="headingCell1">ITEM SOURCE</div>
<div id="item_source" style="padding:8px 8px 12px 8px;">
<?php 		
	//editing an electronic item - show URL/upload fields
	if($this->item->getItemGroup() == 'ELECTRONIC'){
?>
	<script language="JavaScript">
			
		function toggleItemSourceOptions(option_id) {
			
			document.getElementById('item_source_upload').style.display = 'none';
			document.getElementById('item_source_link').style.display = 'none';
			if(document.getElementById(option_id)) {
				document.getElementById(option_id).style.display = '';
			}
						
			currentItemSourceOptionID = option_id;
		}
	</script>		
	
	<div style="overflow:auto;" class="strong">
		Current URL <small>[<a href="?cmd=viewReserve&item=<?php print($this->item->getItemID());?>" target="_blank">Preview</a>]</small>: 
<?php		if($this->item->isLocalFile()){ //local file ?>
				Local File 
<?php			if(Account_Rd::atLeastStaff()){ //only show local path to staff or greater ?>
				 &ndash; <em><?php print($this->item->getURL()); ?></em>
<?php			} ?>
<?php		} else { //remote file - show link to everyone ?>
				<em><?php print($this->item->getURL());?></em>
<?php		} ?>
	</div>
	<small>
		Please note that items stored on the ReservesDirect server are access-restricted; use the Preview link to view the item.
		<br/>
		To overwrite this URL, use the options below.
	</small>
	<br/>
	<div>
	<?php 
		$urlProvided = $this->request && Rd_Array::keyExistsAndNotBlank('url', $this->request);
		$selectedDocType = 
			$this->request && Rd_Array::keyExistsAndNotBlank('documentType', $this->request)
			? $this->request['documentType']
			: ($this->item->isLocalFile() ? 'DOCUMENT' : 'URL' );
		$selectedUrl = 
			$urlProvided 
			? $this->request['url'] 
			: (
				!$this->item->isLocalFile()
				? $this->item->getUrl()
				: ''
			);
		$invalidUrl = $selectedDocType == 'URL' && !Validator_Url::validate($selectedUrl);
		$changeChecked = 
			$invalidUrl
			? ' checked="checked"' 
			: '';
		$keepChecked = '' == $changeChecked ? ' checked="checked"' : '';
	?>
		<input type="radio" name="documentType"<?php print($keepChecked); ?> onclick="toggleItemSourceOptions('');" /> Maintain current URL &nbsp;
		<input type="radio" name="documentType" value="DOCUMENT" onclick="toggleItemSourceOptions('item_source_upload');" /> Upload new file &nbsp;
		<input type="radio" name="documentType"<?php print($changeChecked); ?> value="URL" onclick="toggleItemSourceOptions('item_source_link');" /> Change URL
	</div>
	<div style="margin-left:40px;"<?php if($invalidUrl) { print(' class="invalid"'); } ?>>
		<div id="item_source_upload" style="display:none;">
			<input type="file" name="userFile" size="50" />
		</div>
		<div id="item_source_link" <?php if (!$invalidUrl) { print('style="display:none;"'); } ?>>
			<input name="url" type="text" size="50" value="<?php print(htmlentities($selectedUrl));?>"/>
			<input type="button" onclick="openNewWindow(this.form.url.value, 500);" value="Preview" /> <?php if ($invalidUrl) {?><span class="hintText">Please provide a valid URL.</span><?php } ?>
		</div>
	</div>
</div>
<?php 
}
		//editing a physical item - show library, etc.
		//only allow staff or better to edit this info
if(Account_Rd::atLeastStaff()){	 
						//$status = $reserveItem->getStatus();
				//$$status = " checked='CHECKED' ";
				
	switch($this->item->getStatus()) {
		case 'ACTIVE':
			$item_status_active = "checked='CHECKED'";
			$item_status_denied = '';
			break;
		case 'DENIED':
			$item_status_active = '';
			$item_status_denied = "checked='CHECKED'";
	}
				
			?>
<div style="overflow:auto;">
	<p><strong>Item Status:</strong>
		<div>
			<input type="radio" name="item_status" <?php print($item_status_active); ?> value="ACTIVE"/> <span class="active">Activate for all Classes</span> (may still be denied on a course by course basis)
			<br />
			<input type="radio" name="item_status" <?php print($item_status_denied); ?> value="DENIED"/> <span class="inactive">Deny use for all Classes</span> (cannot be overridden on a course by course basis)
		</div>
	</p>
</div>
<table class="topMargin bottomMargin" border="0" cellpadding="2" cellspacing="0">	
	<tr>
		<td align="right">
			<strong>Reserve Desk: </strong>
		</td>
		<td>
			<select name="home_library">
<?php
			foreach(Rd_Library::getAll() as $lib){
				$selected_lib = ($this->item->getHomeLibraryID() == $lib->getLibraryID()) ? 'selected="selected"' : '';
?>
				<option value="<?php print($lib->getLibraryID()); ?>"<?php print($selected_lib); ?>><?php print($lib->getLibrary()); ?></option>			
<?php		} ?>
		</select>
		</td>
	</tr>
</table>
<?php
} else { 
	$homeLibrary = '';
	$lib = new library($reserveItem->getHomeLibraryID());
	$homeLibrary = $lib->getLibraryName();
?>
		
<p class="topMargin" ><strong>Item Status:</strong> <?php print($this->item->getStatus()); ?></p>
		<?php if('' != trim($homeLibrary)) { ?><p><strong>Home Library:</strong> <?php print($homeLibrary); ?></p><?php } ?>
		<?php
}
		 //details from the physical copy table (barcode/call num)
if(Account_Rd::atLeastStaff() && $this->item->getPhysicalCopy()){
?>
<p>This item has one or more physical copies.</p>
<?php	} else if (Account_Rd::atLeastStaff()) { ?>
<p>This item is not associated with any physical copies.</p>
<?php } ?>